import { initFactor } from './service/initFactor';
import { uploadFactor } from './service/uploadFactor';
import { instanceParamsType, uploadParamsType } from './type';

// 初始化上传类
class ObjectStorage {
  instance: any;
  bucketName: string | undefined;
  uploadType: string;

  constructor(params: instanceParamsType) {
    this.instance = initFactor(params ?? {});
    this.bucketName = params.bucketName;
    this.uploadType = params.type;
  }

  upload(params: uploadParamsType) {
    return uploadFactor({
      uploadType: this.uploadType,
      instance: this.instance,
      bucketName: this.bucketName,
      params,
    });
  }
}

export default ObjectStorage;
